//package com.hna.face.task;
//
//import java.text.SimpleDateFormat;
//import java.util.Calendar;
//import java.util.Date;
//import java.util.List;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.PropertySource;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import com.hna.face.model.ScheduleStat;
//import com.hna.face.service.IScheduleStatService;
//import com.hna.face.util.Config;
//
//
////@PropertySource("classpath:config/config.properties")//加载指定文件
//@Component
//public class ScheduleStatTask {
//	
//	@Autowired
//	private IScheduleStatService scheduleStatService;
//	
//	private final static Logger log = LoggerFactory.getLogger(ScheduleStatTask.class);
//
//	 /**
//	   *	 每天凌晨2点备份前一天的数据
//	   */
//	@Scheduled(cron = "${bot.city-sync-schedule}", zone = "${bot.time-zone}")
//	public void scheduleStatBackups() {
//		 Calendar instance = Calendar.getInstance();
//		 instance.add(Calendar.DATE, -1);//得到前一天
//		 String date = new SimpleDateFormat("yyyy-MM-dd").format(instance.getTime());
//		 log.info(date);
//		 //通过日期前一天获取到的数据
//		 List<ScheduleStat> list= scheduleStatService.selectTack(date);
//		 log.info(list.size()+"");
//		//对获取到的数据失败率进行计算
//		 for (ScheduleStat stat : list) {
//			 stat.setCreateTime(new Date());
//			 stat.setDay(new Date());
//			 if(stat.getFailTimes()==null) {
//				 stat.setFailRate((float)0);
//			 }else {
//				 stat.setFailRate((float)(stat.getFailTimes()/stat.getTotalTimes())*100);
//			 }
//		}
//		 //备份到数据库
//		boolean insertBatch =scheduleStatService.insertBatch(list);
//		log.info(insertBatch+"");
//	 }
//}
